﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jay.Sc2.Bof.Lib.State;

namespace Jay.Sc2.Bof.Lib.Action
{
	public class ActionSendScout : Action
	{
		public static ActionSendScout Instance = new ActionSendScout();

		private ActionSendScout() { }
		public override bool CanExecute(IBuildOrder bo) { return bo.State.WorkersOnGas + bo.State.WorkersOnMinerals > 0; }
		public override bool HaveResources(IBuildOrder bo) { return bo.State.WorkersOnGas + bo.State.WorkersOnMinerals > 0; }
		public override bool HaveTechnology(IBuildOrder bo) { return true; }
		public override bool IsInvalid(IBuildOrder bo) { return bo.State.WorkersOnGas + bo.State.WorkersOnMinerals == 0; }
		public override void Execute(IBuildOrder bo)
		{
			if (bo.State.WorkersOnMinerals > 0)
				bo.State.WorkersOnMinerals--;
			else if (bo.State.WorkersOnGas > 0)
				bo.State.WorkersOnGas--;
			else throw new Exception();
			bo.State.ScoutsSent++;
		}
	}
}
